<template> 
  <div class="app-container">
      <div class="ces-main">
<div ref="headRef">


        <el-row>
<el-col :span="18"><div class="grid-content bg-purple"></div><Search-Form 
        ref="form"
        size='mini'
        labelWidth = '50px' 
        align="left"
        :searchData = 'Search'
         :tableCols = 'tableCols'
        :searchHandle="searchHandle"
        @handleEnter="refresh"></Search-Form ></el-col>
<el-col :span="6"><div class="grid-content bg-purple-light">
  <!-- <v-GetToolBar align="right" :key="MenuCode" :MenuCode='MenuCode'  
        :IsfunEdit='IsfunEdit'
        :Isfunfail='Isfunfail'
        @handeAdd='handeAdd'
        @handleEdit='handleEdit'
        @OpenFindForm='OpenFindForm'
        @handlexportData='handlexportData'
        @IsfunEdit='handleIsfunEdit'
        @handesave='handleAllSave'
        @handeprint="'#PrintDate-id'"
        @IsfunDelete='handleIsfunfail'
          @handleclose='handleclose'
        ></v-GetToolBar> -->

        <el-button type="primary" icon="el-icon-search" size="mini" v-on:keydown.enter="OpenFindForm()" @click="OpenFindForm()">查询</el-button>

        <el-button type="warning" icon="el-icon-circle-plus-outline" @click="handleAllSave()" size="mini"  >保存</el-button> 
        <el-button  type="warning" icon="el-icon-circle-plus-outline" v-print="'#PrintDate-id'" size="mini"  >打印</el-button>     
       
  
      </div></el-col>
</el-row>
<!-- <el-button size="medium" v-print="'#PrintDate-id'" icon='el-icon-check' >打印</el-button> -->

<el-tabs v-model="activeName" @tab-click="handleClick">
    <el-tab-pane label="排产" name="first"> 
      <ces-table 
          size='mini'
        
          :isSelection='false'
          :isIndex='true'
          :isSearch='true'
          :isHandle='false'
          :StepSN = '0'
          :IsfunEdit='IsfunEdit'
           :Isfunfail='Isfunfail'
          :tableData='tableData' 
          :tableColumns='tableCols' 
          :height="tableheight"
          :pagination='Search'
          @refresh="refresh"
          @handleEdit='handleEdit'
          @handleDelete='delData'
          :tableLoading="tableLoading[0]"
          @workbookInitialized="workbookInitialized"
          @selectChanged="selectChanged"
          :ToolBarheight='ToolBarheight'
          :remark="0"
          :sysID="0"
          >
          </ces-table>
  </el-tab-pane>
    <el-tab-pane label="" name="second">  <div id="PrintDate-id">
    <table style="border: 1px solid black">
      <tr style="border: 1px solid black">
        <td>订单号</td>
        <td>产品编号</td>
        <td>产品名称</td>
        <td>数量</td>
      </tr>
      <tr style="border: 1px solid black" v-for='(item, index) in selectionData'>
        <td>{{item.OrderNo}}</td>
        <td>{{item.ProductNo}}</td>
        <td>{{item.ProductName}}</td>
        <td>{{item.Qty}}</td>
      </tr>
    </table>
  </div>
      </el-tab-pane>

  </el-tabs>


  





</div>
         
          </div>
  
   <!--搜索弹框-->
      <el-dialog
        title="搜索"
        :visible.sync="SearchDialog"
        custom-class="dialogClass"
        class="searchDialog"
        center
        ref="searchDialog"
        :modal="false"
        :close-on-click-modal="false"
      >
        <el-form :model="Search" label-width="90px" ref="searchForm">
         
     
  
        <Search-Form 
        :frame="true"
          ref="form"
          size='mini'
          labelWidth = '50px' 
          :searchData = 'Search'
        
           :tableCols = 'tableCols'
          :searchHandle="searchHandle"></Search-Form >
        </el-form>
        
        <div
          slot="footer"
          :style="{ 'margin-buttom': 0 == 0 ? DialogBtnMargin : DialogBtnMargin }"
        >
          <el-button @click="reform()">重置</el-button>
          <el-button type="primary" @click="refresh()">确 定</el-button>
        </div>
      </el-dialog>
  
  
  
      <el-dialog
        v-if="dialogVisible"
        :visible.sync="dialogVisible"
        width="800px"
        top="20px"
         
      >
  <el-form :model="name" label-width="80px"  label-position="right">
     <el-tabs type="border-card">
          <el-tab-pane label="类别管理">
        <el-form :model="FormData" label-width="90px" ref="MianForm">
         <Mian-Form 
          ref="form"
          :StepSN = '0'
          labelWidth = '100px' 
          :FormData = 'FormData'
           :tableCols = 'tableCols'
          :searchHandle="searchHandle"></Mian-Form >
        </el-form>
          </el-tab-pane>
  <div style="float:right ">
  
   <el-button type="primary" @click="handleOpenClose()">关闭</el-button>
          <el-button type="primary" @click="handleSave()">保存</el-button>
  
  </div>
         
    </el-tabs>
        
  </el-form>
       
      </el-dialog>
  
  
  </div>
  </template>
  
  <script>
  
  
  //引入组件
  var _this;
const GCsheets = GC.Spread.Sheets;
import '@grapecity/spread-sheets-vue';
import GC from '@grapecity/spread-sheets';
import '@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css';
import '@grapecity/spread-sheets/js/zh.js';
import { mapState } from 'vuex';
GC.Spread.Common.CultureManager.culture('zh-cn');
  import cesTable from "../Common//ComSpreadTable.vue";
  import { HeaderCheckBoxCellType } from '@/static/data.js';
  //import cesTable from "../Common//table.vue";
  import { PrintDate } from "@/api/Print";
  import SearchForm from "../Common//Search.vue";
  import MianForm from "../Common//form.vue";
  
  import { funDownload,GetTableColsData,SaveData } from "@/api/Common";
  import { getDataList,UpdateForm,DeletForm,APSschedulingUpdate} from '@/api/APSscheduling/APS';
  import vGetToolBar from "../Common/GetToolBar";
import a from 'file-saver';
import { forEach } from 'jszip/lib/object';
  
  
  export default {
    name:"ManualScheduling",
      data(){
           //表单查询一般分为input，下拉框，和日期，下面是下拉框时的设置下拉信息的情况，我的项目没有用到，但是留着方便看
        
          return {
          MenuCode: "A051202",
          tableData:[],//表格数据
          FormData:[],//表格数据
          tableCols:[ ],//表格列数据
          searchHandle:[],
          StepSN:"0",
          IsfunEdit:false,
            Isfunfail:false,
            ToolBarheight:280,
          Search: {
          // 查询条件
          total: 0, // 总记录数
          pageSize:50, // 一页显示的记录数
          page: 1, // /当前页码
          InterID: "1586", // 表编号  根据Controller中对应的表编号
          RNO: "1586", // 表编号  根据Controller中对应的表编号
          jsWhere: ""// 自定义条件
         
         
        },  tableLoading: [false, false, false, false],
        spread: [[], [], []],
        selectionData: [[], [], []],
        Indexs:null,
        activeName: 'first',
         cities: [
          {
            value: "0",
            label: "未下达",
          },
          {
            value: "1",
            label: "已下达",
          },
          {
            value: "ALL",
            label: "ALL",
          }
          
        ],
         SearchDialog: false,
           DialogBtnMargin: 0,
           dialogVisible: false,
           tableheight:"540px",
            
          }
      },
  
     components:{ //引入组件后注册组件
      cesTable, 
       vGetToolBar,
       SearchForm,
       MianForm
     },
     async mounted(){
    
    
     //await this.getTableCols()
     await this.getDataList()
   
   

     },
      methods:{
           //搜索重置
      refresh(type) {
      
        debugger
        if(type.index==2)
        {
          this.Search = {
          // 查询条件
          total: 0, // 总记录数
          pageSize:50, // 一页显示的记录数
          page: 1, // /当前页码
          InterID: "1586", // 表编号  根据Controller中对应的表编号
          RNO: "1586", // 表编号  根据Controller中对应的表编号
          jsWhere: "", // 自定义条件
        };
        }else if(type.index==0)
        {
          this.Search = {
          // 查询条件
          total: 0, // 总记录数
          pageSize:50, // 一页显示的记录数
          page: 1, // /当前页码
          InterID: "1586", // 表编号  根据Controller中对应的表编号
          RNO: "1586", // 表编号  根据Controller中对应的表编号
          jsWhere: "", // 自定义条件
         
        };
        }else if(type.index==1)
        {
          this.Search = {
          // 查询条件
          total: 0, // 总记录数
          pageSize:50, // 一页显示的记录数
          page: 1, // /当前页码
          InterID: "1586", // 表编号  根据Controller中对应的表编号
          RNO: "1586", // 表编号  根据Controller中对应的表编号
          jsWhere: "", // 自定义条件
        
        };
        }
     
        this.getDataList();

       
      }, workbookInitialized: function (workbook, remarkTb) {

    this.spread[remarkTb] = workbook;
  },
       reform() {
         this.Search = {
          // 查询条件
          total: 0, // 总记录数
          pageSize:50, // 一页显示的记录数
          page: 1, // /当前页码
          InterID: "1586", // 表编号  根据Controller中对应的表编号
          RNO: "1586", // 表编号  根据Controller中对应的表编号
          jsWhere: "", // 自定义条件
        };
         this.getDataList();
      },
        //读取列配置
          async getTableCols(){
          this.tableCols = []
          const res = await  GetTableColsData({InterID:"1586"});
          this.tableCols=res.data;
  
              //选添选择
              let row = {
          prop: 'isChecked',
          label: '选择',
          width: 80,
          IsWrite: 1,
          WFStepSN: '-1',
          type: '',
      };

      this.tableCols.unshift(row);
     
    
           },
           async setData(remarkTb) {
            
        this.spread[0].suspendPaint();
         let sheet = this.spread[0].getActiveSheet();

    
  
    sheet.options.protectionOptions.allowSort = false;
    sheet.options.protectionOptions.allowFilter = false;
  //       sheet.options.allowCellOverflow = true;
        sheet.defaults.rowHeight = 23;
        sheet.defaults.colWidth = 100;
        sheet.defaults.colHeaderRowHeight = 23;
        sheet.defaults.rowHeaderColWidth = 60;
        this.spread[remarkTb].options.tabStripVisible = false; //是否显示表单标签
        let colHeader1 = [];
        let colInfos = [];
      
        sheet.setDataSource(this.tableData);
       
  
        debugger
          this.tableCols.forEach((x, y) => {
          
          x['name'] = x['prop'];
          x['displayName'] = x['label'];
          x['width'] = parseInt(x.width);
          if (x.prop === 'isChecked') {
            // 选框
            sheet.setCellType(
              0,
              0,
              new HeaderCheckBoxCellType(),
              GCsheets.SheetArea.colHeader,
            );
            x.cellType = new GC.Spread.Sheets.CellTypes.CheckBox();
          } else if (
            x.type === 'comboboxMultiple' ||
            x.type === 'combobox'||x.type==='Select'
          ) {
            if (x.ValueMember) {
            
                let newData = []; // 设置列表每行下拉菜单
             x.ColsRowDate.map((item, index) => {
              
              let row = {
                text: item.label,
                value: item.value,
      };
               newData.push(row);
             

            });

           // newData.push(item.value);
              
                this.tableData.forEach((x, y1) => { 
                  debugger
                // 获取要绑定下拉菜单的单元格对象
                let cell = sheet.getCell(y1, y);
                // 创建下拉菜单单元格类型，并设置其选项数据
                let comboBox = new GC.Spread.Sheets.CellTypes.ComboBox();
                comboBox.editorValueType(
                  GC.Spread.Sheets.CellTypes.EditorValueType.value,
                );
                comboBox.editable(true);
                // 获取下拉菜单的选项数据
                comboBox.items(newData);
                comboBox.itemHeight(24);
                // 将下拉菜单单元格类型绑定到指定的单元格中
                cell.cellType(comboBox);
                })
          }
              
            
          } else if (x.type === 'checkbox') {
            let cellType = new GC.Spread.Sheets.CellTypes.CheckBox();
            cellType.caption('');
            cellType.textTrue('');
            cellType.textFalse('');
            cellType.textIndeterminate('');
            cellType.textAlign(
              GC.Spread.Sheets.CellTypes.CheckBoxTextAlign.center,
            );
            cellType.isThreeState(false);
            sheet.getCell(-1, y).cellType(cellType);
          } else if (
            x.type == 'datetime' ||
            x.type === 'varchar' ||
            x.type === 'nvarchar'||x.type === 'Input'
          ) {
            // const cell = sheet.getCell(-1, y);
            // cell.locked(false).foreColor('#2a06ecd9');
            // sheet.getRange(-1, y, 1, 1).locked(false);
            x.formatter = '@';
          }

          const cell = sheet.getCell(-1, y);
            cell.foreColor('black');
          //cell.backColor('white');
            if((x.IsWrite == '1'&&x.WFStepSN.indexOf(this.StepSN)>-1)||x.prop=='isChecked')
            {
              cell.locked(false).foreColor('#2a06ecd9');
              //cell.backColor('#45b97c');
        
            }else if(x.prop!='isChecked')
            {
              
            }

    sheet.options.protectionOptions.allowResizeColumns = true;
    sheet.options.isProtected = true;
    sheet.options.protectionOptions.allowResizeColumns = true;
    sheet.options.protectionOptions.allowInsertRows = true;
    sheet.options.protectionOptions.allowDeleteRows = true;
    sheet.options.protectionOptions.allowSelectLockedCells = true;
    sheet.options.protectionOptions.allowSelectUnlockedCells = true;
    sheet.options.protectionOptions.allowDeleteColumns = true;
    sheet.options.protectionOptions.allowInsertColumns = true;
    sheet.options.protectionOptions.allowDargInsertRows = true;
    sheet.options.protectionOptions.allowDragInsertColumns = true;
    sheet.options.protectionOptions.allowSort = true;
    sheet.options.protectionOptions.allowFilter = true;
    sheet.options.allowUserDragDrop = true;
          //行，start,end
          // if (x.isEdit) {
          //   sheet.getCell(-1, y).locked(false).foreColor("#2a06ecd9");
          // }

          // for (var i = 0; i < sheet.getRowCount(); i++) {
         
          //   const cell = sheet.getCell(i, y);
          //   cell.foreColor('black');
          // //cell.backColor('white');
          //   if(x.IsWrite == '1'&&x.WFStepSN.indexOf(this.StepSN)>-1)
          //   {
          //     cell.locked(false).foreColor('#2a06ecd9');

          //   }else if(x.prop!='isChecked')
          //   {
              
          //   }
            

          // }


        }
        
        );
 
        sheet.bindColumns(this.tableCols); //此方法一定要放在setDataSource后面才能正确渲染列名
        sheet.setRowCount(1, GC.Spread.Sheets.SheetArea.colHeader);
        colHeader1.forEach(function (value, index) {
          sheet.setValue(0, index, value, GC.Spread.Sheets.SheetArea.colHeader);

          
      });  


      /////////////////表格事件/////////////
    //绑定表格事件前，需清除之前的绑定事件
    this.spread[remarkTb].unbindAll();
    this.spread[remarkTb].bind(GCsheets.Events.ButtonClicked, (e, args) => {
      const { sheet, row, col } = args;
      const cellType = sheet.getCellType(row, col);
      if (cellType instanceof GCsheets.CellTypes.Button) {
      }
      if (cellType instanceof GCsheets.CellTypes.CheckBox) {

                    this.Indexs=row;
                 
        
      }
      
      if (cellType instanceof GCsheets.CellTypes.HyperLink) {
      }
    });

      this.spread[0].options.allowContextMenu = true;
      var insertRowsCopyStyle = {
      canUndo: true,
      name: 'insertRowsCopyStyle',
      execute: function (context, options, isUndo) {
        var Commands = GC.Spread.Sheets.Commands;
        if (isUndo) {
          Commands.undoTransaction(context, options);
          return true;
        } else {
          sheet.suspendPaint();
          sheet.addRows(options.activeRow, _this.sheetSelectRows.length);
          //  sheet.setArray(options.activeRow, 0,_this.sheetSelectRows);
          // console.log(_this.sheetSelectRows);

          // console.log(_this.sheetSelectObj.start+_this.sheetSelectRows.length)
          //删除旧行
          if (_this.sheetSelectObj.start > options.activeRow) {
            //说明从下面插入上面
            sheet.copyTo(
              _this.sheetSelectObj.start + _this.sheetSelectRows.length,
              0,
              options.activeRow,
              0,
              _this.sheetSelectRows.length,
              sheet.getColumnCount(),
              GC.Spread.Sheets.CopyToOptions.all,
            );

            //   sheet.setArray(options.activeRow, 0, _this.sheetSelectRows);
            sheet.deleteRows(
              _this.sheetSelectObj.start + _this.sheetSelectRows.length,
              _this.sheetSelectObj.count,
            );
            // sheet.removeRow(_this.sheetSelectObj.start+ _this.sheetSelectRows.length)
          } else {
            //从上面往下面插入
            sheet.copyTo(
              _this.sheetSelectObj.start,
              0,
              options.activeRow,
              0,
              _this.sheetSelectRows.length,
              sheet.getColumnCount(),
              GC.Spread.Sheets.CopyToOptions.all,
            );
            //  sheet.setArray(options.activeRow, 0, _this.sheetSelectRows);
            sheet.deleteRows(
              _this.sheetSelectObj.start,
              _this.sheetSelectObj.count,
            );
          }
          let count = sheet.getRowCount(GC.Spread.Sheets.SheetArea.viewport);

          let lineID = _this.sheetSelectRows[0][lineIDIndex];
          let isFind = false;
          let viewSort = 1;

          for (var i = 0; i < count; i++) {
            if (isFind == false && sheet.getValue(i, lineIDIndex) == lineID) {
              isFind = true;
            }
            if (isFind && sheet.getValue(i, lineIDIndex) != lineID) {
              break;
            }
            if (isFind) {
              sheet.setValue(i, viewSortIndex, viewSort);
              viewSort++;
            }
          }

          // Commands.startTransaction(context, options);

           sheet.suspendPaint();

          // var beforeRowCount = 0;

          //  sheet.suspendPaint();

          // Commands.endTransaction(context, options);
          sheet.resumePaint();

          return true;
        }
      },
    };

    this.spread[remarkTb]
      .commandManager()
      .register('insertRowsCopyStyle', insertRowsCopyStyle);
      
      function MyContextMenu() {}
    MyContextMenu.prototype = new GC.Spread.Sheets.ContextMenu.ContextMenu(
      this.spread[remarkTb],
    );
    MyContextMenu.prototype.onOpenMenu = function (
      menuData,
      itemsDataForShown,
      hitInfo,
      spread,
    ) {
      itemsDataForShown.forEach(function (item, index) {
        // console.log(item);
        if (item && item.name === 'gc.spread.rowHeaderinsertCutCells') {
          item.command = 'insertRowsCopyStyle';
        }
        //  else if (item && item.name === "gc.spread.cut") {

        //     item.command = "insertRowsCut";
        //   }
      });
    };
    var contextMenu = new MyContextMenu();
    this.spread[remarkTb].contextMenu = contextMenu;
     

// 列筛选
    // 参数2 开始列
    // 参数3
    // 参数4 结束列
    let cellrange = new GC.Spread.Sheets.Range(
      -1,
      -1,
      -1,
      this.tableCols.length,
    );
    let hideRowFilter = new GC.Spread.Sheets.Filter.HideRowFilter(cellrange);
    sheet.rowFilter(hideRowFilter);


    debugger

let count = sheet.getRowCount(GC.Spread.Sheets.SheetArea.viewport);
               sheet.addRows(count+1,1);
               sheet.setValue(count, 1, "合计:");
               sheet.setFormula(count, 13, '=SUM(N1:N20)');

sheet.resumePaint();

  
           }, getSelectionData() {
    let sheet = this.spread.getActiveSheet();
    let newData = sheet.getDataSource();
    this.selectionData[0] = [];
    if (newData.length != 0) {
      newData.forEach((x) => {
        if (x.isChecked) {
          this.selectionData[0].push(x);
        }
      });
    }
  }, //获取当前选中行的值
  selectChanged(newValue, remarkTb) {
    // 在子组件计算属性发生变化时，更新父组件的计算属性
    debugger
    this.selectionData= newValue;
  },
          async getDataList() {
          const res = await getDataList({ data: JSON.stringify(this.Search) });
          
          //将data 中的数据放到DataList中
          this.Search.total = res.data.Table1[0].RecordCount;
          this.tableCols=res.data1;


          let row = {
          prop: 'isChecked',
          label: '选择',
          width: 50,
          IsWrite: '1',
          WFStepSN: '-1',
          type: '',
      };

      this.tableCols.unshift(row);
      setTimeout(() => {
      this.setHeight();
    }, 450);

    this.tableData = res.data.Table;
           this.setData(0);
      },  setHeight() {
      let headHeight = this.$refs.headRef.offsetHeight;

      let rem =
        document.documentElement.clientHeight-headHeight-140;
      let newHeight = rem + 'px';
      this.tableheight=newHeight;
    //   alert(this.tableheight);
    //  this.$set(this, 'height', newHeight);
    },OpenFindForm() {
          this.getDataList();
        //打开搜索框
      //   this.SearchDialog = true;
      //   //计算外边距
      //   console.log(this.$refs.searchDialog.offsetHeight);
      //   this.DialogBtnMargin = this.$refs.searchDialog.offsetHeight - 40;
      },
      handleOpenClose()
      {
          this.dialogVisible = false
      }, handlexportData() {
        funDownload("1585", JSON.stringify(this.Search));
      }, handleIsfunEdit() {
        this.IsfunEdit=true;
      }, handleIsfunfail() {
         this.Isfunfail=true;
      },async handeAdd() {
        // 新建
      const result = await UpdateForm({ IsPostBack:false,billID:''});
       this.FormData=result.data1.Table[0];
       this.dialogType = 'edit'
          this.dialogVisible = true
          this.checkStrictly = true
        
          this.$nextTick(() => {
            const routes = this.generateRoutes(this.EditObj.routes)
            this.$refs.tree.setCheckedNodes(this.generateArr(routes))
            // set checked state of a node not affects its father and child nodes
            this.checkStrictly = false
            this.getDataList();
  
          })
         
      },
     async handleEdit(scope) {
        // 修改
  
        
      const result = await UpdateForm({ IsPostBack:false,billID:scope.row.IDXNO});
       this.FormData=result.data1.Table[0];
          this.dialogType = 'edit'
          this.dialogVisible = true
          this.checkStrictly = true
        
          this.$nextTick(() => {
            const routes = this.generateRoutes(this.EditObj.routes)
            this.$refs.tree.setCheckedNodes(this.generateArr(routes))
            // set checked state of a node not affects its father and child nodes
            this.checkStrictly = false
  
          })
          this.getDataList();
        
      },
       async handleSave(scope) {
        // 修改
        
      const result = await UpdateForm({ IsPostBack:true,billID:this.FormData.IDXNO, HeadDate: JSON.stringify(this.FormData)});
       this.FormData=result.data1.Table[0];
         
          if (result.code === 20000) {
           
         
            this.$notify({
              title: result.msg,
              dangerouslyUseHTMLString: true,
              message: "",
              type: "success",
            });
            this.getDataList();
          } else {
            this.$notify({
              title: result.msg,
              dangerouslyUseHTMLString: true,
              message: "",
              type: "error",
            });
          }
        
         
          this.getDataList();
        
      }  ,async PrintDate () 
    {
      // 提交数据，需要修改
debugger
     await PrintDate('T20240118004',this.selectionData,this.selectionData[0],2);
    
      
    
    } ,printDatas() {
      const data = this.selectionData; // 获取动态数据
      
      // 创建新的 window 对象，将数据传递到新页面中
      const newWindow = window.open('', '_blank');
      newWindow.document.write(data);
      newWindow.document.close();
      newWindow.focus();
      newWindow.print();
    },async handleAllSave(scope) {
        // 修改
        let options="保存中...";
          const loading = this.$loading({
          lock: true,
          text: options,
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        this.spread[0].suspendPaint();
           let sheet = this.spread[0].getActiveSheet();
debugger
if (sheet && sheet.isEditing()) {
        sheet.endEdit();
      }

        let DirtyRows = sheet.getDirtyRows().map((row) => row.item); //获取修改过的数据
        // let InsertRows = sheet.getInsertRows().map((row) => row.item); //获取插入过的数据
        //   for (let v of InsertRows) 
        //   {
        //     DirtyRows.push(row);
        //   }
          sheet.resumePaint();
          //let DeletedRows = sheet.getDeletedRows().map((row) => row.item);
          if (DirtyRows.length == 0) {

        this.$message.error('当前数据没做修改，请先修改再保存！');
        loading.close();
        return;
      }
     
      

       const result = await APSschedulingUpdate({ InterID:'1586', BodyDate: JSON.stringify(DirtyRows)});

       loading.close();

    
       if (result.code === 20000) {
           
         
           this.$notify({
             title: result.msg,
             dangerouslyUseHTMLString: true,
             message: "",
             type: "success",
           });
           this.getDataList();
         } else {
           this.$notify({
             title: result.msg,
             dangerouslyUseHTMLString: true,
             message: "",
             type: "error",
           });
         }
        
      }, FunrRowsAdd () {
        debugger
        let row = {
          IDXNO: null,
          NAME: null,
          IDXUP: null,
          LB: null,
          ID: null,
         
      };

      // this.tableData.push(row);
     
        this.spread[0].suspendPaint();
           let sheet = this.spread[0].getActiveSheet();
         let count = sheet.getRowCount(GC.Spread.Sheets.SheetArea.viewport);
             sheet.addRows(count+1,1);
          //sheet.suspendPaint()

          sheet.resumePaint()

      


      },FunCopyRowsAdd () {
      
//           debugger
//           this.spread[0].suspendPaint();
//            let sheet = this.spread[0].getActiveSheet();
// let count = sheet.getRowCount(GC.Spread.Sheets.SheetArea.viewport);
//      sheet.copyTo(this.Indexs, 1, count-1, 1, 1,  sheet.getColumnCount(), GC.Spread.Sheets.CopyToOptions.style);
// //           for (var row of  this.selectionData) {     
// //             row["ID"]=null;
// //             row["isChecked"]=null;
// //             this.tableData.push(row);
// //             sheet.addRows(row,null);
// //     }
// // debugger
// //       t
// sheet.resumePaint()
  //sheet.setDataSource(this.tableData);
this.$nextTick(() => {
        sheet.repaint();
      });


     
      },
      delData() {
         this.$confirm('删除操作, 是否继续?', '提示', {
          confirmButtonText: "确认",
          cancelButtonText: "取消",
        })
          .then(async () => {
           
       this.spread[0].suspendPaint();
           let sheet = this.spread[0].getActiveSheet();
         sheet.deleteRows(this.Indexs,1);
         sheet.resumePaint()
         debugger
            for (var row of  this.selectionData) {     
  


              //

              // const result = await DeletForm({
              //   billID: row.IDXNO,
              //   IsPostBack: false,
              // });
  
              // this.$message({
              //   type: "success",
              //   message: result.msg,
              // });

            }
          
           // this.getDataList();
            
          })
          .catch((err) => {
            console.error(err);
          });

      },
        
         
    }
  }
  </script>
  
  <style lang="scss" scoped>
  
  .app-container {
    .EditObjs-table {
      margin-top: 30px;
    }
  
    .permission-tree {
      margin-bottom: 5px;
    }
  }
  .searchDialog ::v-deep .el-dialog__header {
    background: #409eff;
  }
  .searchDialog ::v-deep .el-dialog__title {
    color: #fff;
  }
  .searchDialog ::v-deep .el-dialog__headerbtn .el-dialog__close {
    color: #fff;
  }
  </style>